Skip to main content

All Questions

0votes
0answers
10views

Algorithm for maximizing log-sum of point weights under chain constraint in 2D dominance game

I'm working on a problem as part of my university studies that involves developing algorithms or heuristics for a 2D point-based optimization game. I'd appreciate ideas, insights, or references to ...
user3043698's user avatar
-1votes
1answer
37views

What is correct path tracking in Floyd-Warshall algorithm?

There are several descriptions of the Floyd-Warshall algorithm, including the one in Wikipedia where path tracking logic described like in the pseudo-code below (copy from Wikipedia https://en....
RomanGirin's user avatar
2votes
2answers
69views

Getting all distinct subsets from subset sum problem with target T using Dynamic Programming

In the classic subset sum problem, there are a set S and a target t, and the goal is to find a subset of S whose sum is t. This variant has a pseudo-polynomial time solution. In a variant of the ...
Samuel Bismuth's user avatar
4votes
1answer
76views

Struggling with bottom up approach for This Kattis Problem: The mailbox manufacturers

Problem link : https://open.kattis.com/problems/mailbox It feels like a variation of Egg dropping problem but i cant seem to wrap my head around how I am unable to do this. It is also tagged as an ...
Karma's user avatar
2votes
2answers
80views

Why does my A* algorithm expand nodes differently when using heapq vs. a set for the open set?

I'm implementing an A* search algorithm for a maze solver in Python. Initially, I maintained the open set as a plain set and selected the node with the lowest f-score using: current = min(open_set, ...
Tao's user avatar
  • 31
2votes
2answers
80views

Match indexes from 1 to n with n given arrays so that sum of elements is minimal

Originally I faced a problem: I had three arrays of the same length (say, a, b, c), and I needed to choose indexes i, j, k distinct from each other that the sum a_i + b_j + c_k would be minimal. I ...
horart's user avatar
1vote
2answers
73views

Number of ways to reach A to B by climbing one step, two steps or three steps at a time

I was solving a test on an online platform and the problem statement was similar to this. Stuart has to go from one place to other (A-> B) and he can jump either 1 step, 2 step or 3 steps at a time....
ABGR's user avatar
  • 5,275
-1votes
3answers
133views

Coin change - A test case is failing

The problem goes like this: You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. Return the fewest number of ...
ABGR's user avatar
  • 5,275
2votes
1answer
134views

Maximum the sum of lengths of two nondecreasing subsequence of given array

It is a famous question which asked about finding longest nondecreasing subsequence from a given array. The question is well studied and have O(n log n) time complexity solutions. I have encountered a ...
tsh's user avatar
  • 4,768
3votes
2answers
112views

How to optimize the performance of nested loops with dynamic data structure updates in Python?

How can I optimize this code for better performance while maintaining the correctness of dynamic updates? Is there a way to restructure the nested loop or use a different approach to reduce the time ...
Akash Selvadoss N's user avatar
-1votes
1answer
146views

CSES Elevator Rides why does the solution work?

everyone! While I was solving the problems from cses.fi I came across the one that I totally couldn't understand. I searched the Internet and found the solution with DP along subsets, but still wasn't ...
Ivan_Striker's user avatar
3votes
0answers
52views

Minimum dominating subgraph

A graph G(V,E) is defined by a set of vertices V and a set of edges E. Given W⊆V, find a connected subgraph G'(V',E') of G that satisfies the following conditions: i) ∀p∈V,∃p'∈V' such that p′ is ...
Sword fish's user avatar
0votes
1answer
104views

Knapsack 0/1 variation maximize the number of objects with independent weight restrictions

I'm trying to use dynamic programming to solve a knapsack variation, where you are given an array of containers, each of them having a weight, a resistance and an id, I need to find the tallest pile ...
Nombre de Usuario Genérico's user avatar
1vote
2answers
147views

What is the time complexity of the following algorithm and is there any optimization I can do?

Problem: Given an array that sums to 0, find the maximum number of partitions of it such that all of them sum up to 0 individually. Example: input: [-2, 4, -3, 5, -4] output: 2 (which are [[5, -2, -3]...
figs_and_nuts's user avatar
3votes
4answers
153views

How to efficiently solve the Maximum Product Subarray problem in Python?

I’m trying to solve the Maximum Product Subarray problem, which is described as follows: Given an array of integers (positive, negative, or zero), find the maximum product of any contiguous subarray. ...
Rishal kumar's user avatar

153050per page
close